var app = new Vue({
    el: "#buyTaskList",
    data() {
        return {
            showDialog: true, // 加入购物车弹出层是否显示
            outOfStock_popup: false,
            otherMarket: false,
            quantity: null,
            errMsg: "",
            popup: false,
            moreselAge: "",
            //TODO
            showType: 0, // 0采买任务 1价格纠错 2历史
            listData: [],
            orderType: 0, // 抢单：0，进行中：1,已完成:2
            orderTitle: [
                // 头部
                {
                    type: "抢单",
                    status: "PROCURING"
                },
                {
                    type: "进行中",
                    status: "WAIT_OUT"
                },
                {
                    type: "已完成",
                    status: "FINISHED"
                }
            ],
            currentPage: 1, // 当前页数
            totalPage: 2, // 总页数
            pageSize: 3,
            loading: false,
            orderInfo: {}, // 采买订单详情
            procureStatus: "", // 采买订单商品状态
            goodsIndex: 0,
            checkModel: [],
            conductCheckModel: [],
            checkedAll: false,
            marketKey: "", // 超市名搜索关键字
            marketData: null, // 超市搜索结果列表数据
            // 超市名和超市ID
            market: {
                marketName: "",
                supermarketId: null
            },
            // 商品分享纠错所传参数
            params: {
                startTime: "请选择开始时间",
                endTime: "请选择结束时间",
                price: null, //价格
                priceType: "请选择价格类型", //[价格类型] 正常价：NORMAL  促销价：PROMOTION  处理价：DEAL  会员价：MEMBER
                procureTaskItemId: null // procureTaskItemId
            },
            procureTaskItem: null,
            //纠错商品
            sequence: {
                index: null,
                key: null
            },
            btnDisabled: false,
            headerTitle: "采买任务",
            headerRight_Btn: "历史",
            total: 0, //进行中可选数
            promptOutOfStock: false,
            historyData: [{}, {}, {}, {}], // 历史列表数据
            historyStatus: 0, //采买历史,纠错历史
            createTimeStart: "", // 历史按日期筛选开始时间
            createTimeEnd: "" // 历史按日期筛选结束时间
        };
    },
    watch: {
        checkModel: {
            handler() {
                if (this.orderType === 0) {
                    if (
                        this.checkModel.length === this.listData.length &&
                        this.listData != 0
                    ) {
                        this.checkedAll = true;
                    } else {
                        this.checkedAll = false;
                    }
                    this.procurementTaskIdList = this.checkModel.join(",");
                }
            },
            deep: true // 深度监视
        },
        conductCheckModel: {
            handler() {
                if (this.orderType === 1) {
                    if (this.conductCheckModel.length === this.total && this.total != 0) {
                        this.checkedAll = true;
                    } else {
                        this.checkedAll = false;
                    }
                    this.procurementTaskIdList = this.conductCheckModel.join(",");
                }
            },
            deep: true // 深度监视
        },

        marketKey(val) {
            if (val.length > 0) {
                this.pullUpLoad = true;
                this.currentPage = 1;
                this.getMarketData();
            } else {
                this.marketData = null;
                this.pullUpLoad = false;
            }
        }
    },
    mounted() {
        this.getData();
    },
    filters: {},
    methods: {
        goBack() {
            this.showType = 0;
        },
        changeOne($even, id) {
            if ($even.target.checked) {
                this.checkModel.push(id);
            } else {
                this.checkModel.splice(this.checkModel.indexOf(id), 1);
            }
        },

        changeModel($even, items, index, key) {
            let self = this;
            self.sequence.index = index;
            self.sequence.key = key;
            if ($even.target.checked) {
                if (items.actQuantity) {
                    this.conductCheckModel.push(items.procureTaskItemId);
                } else {
                    self.showPopup(items);
                }
            } else {
                this.conductCheckModel.splice(
                    this.conductCheckModel.indexOf(items.procureTaskItemId),
                    1
                );
            }
        },
        //全选
        changeAllState() {
            this.checkedAll === true ?
                (this.checkedAll = false) :
                (this.checkedAll = true);
            this.checkModel = [];
            this.conductCheckModel = [];
            let list = this.listData;
            if (this.checkedAll === true) {
                if (this.orderType === 1) {
                    for (let i = 0; i < list.length; i++) {
                        for (let j = 0; j < list[i].procureTaskItems.length; j++) {
                            this.conductCheckModel.push(
                                list[i].procureTaskItems[j].procureTaskItemId
                            );
                        }
                    }
                } else {
                    this.listData.forEach((value, index) => {
                        this.checkModel.push(value.procureMergeTasksId);
                    });
                }
            }
        },
        // 选择订单商品状态
        changeOrderStatus(procureStatus, index) {
            this.goodsIndex = index;
            let data = [];
            this.listData[index].procureStatus = procureStatus;
            data = this.listData;
            this.listData = [];
            this.listData = data;
            this.procureStatus = procureStatus;
            if (procureStatus === "LACK") {
                this.showPopup();
            }
        },
        // 更改采买类型tab
        changeOrderType(index) {
            let self = this;
            self.orderType = index;
            self.loading = true;
            self.currentPage = 1;
            this.checkModel = [];
            this.conductCheckModel = [];
            self.listData = [];
            if (self.orderType === 0) {
                self.getData();
            } else {
                self.getProcureTaskItemList();
            }
        },
        // 滚动加载
        loadMore() {
            let self = this;
            self.currentPage++;
            if (self.currentPage > self.totalPage) {
                self.loading = true;
                return false;
            }
            if (self.orderType === 0) {
                self.getData();
            } else {
                self.getProcureTaskItemList();
            }
        },
        /**
         * 采买任务抢单列表
         * pageSize
         * currentPage
         * supermarketId 超市id
         */
        getData() {
            let self = this;
            if (self.market.supermarketId === null) {
                self.errMsg = "请先选择超市";
                setTimeout(() => {
                    self.errMsg = "";
                }, 1000);
            }
            Axios.post("/procurement/procureMergeTasks/getProcureMergeTasksList.do", {
                pageSize: self.pageSize,
                currentPage: self.currentPage,
                supermarketId: self.market.supermarketId
            }).then(function (data) {
                if (data.respCode === "S") {
                    if (self.currentPage == 1) {
                        self.listData = data.data.data;
                    } else {
                        self.listData = self.listData.concat(data.data.data);
                    }
                    self.totalPage = data.data.totalPage;

                    if (self.currentPage < self.totalPage) {
                        self.loading = false;
                    }
                } else {
                    self.listData = [];
                }
            });
        },
        /**
         * 采买任务进行中和已完成列表
         * status:"IN_PROGRESS":进行中"DONE":已完成
         * pageSize
         * currentPage
         */
        getProcureTaskItemList() {
            let self = this;
            let status = "";
            self.orderType === 1 ? (status = "IN_PROGRESS") : (status = "DONE");
            Axios.post("procurement/procureTaskItem/getProcureTaskItemList.do", {
                status: status,
                pageSize: self.pageSize,
                currentPage: self.currentPage,
                supermarketId: self.market.supermarketId
            }).then(function (data) {
                let list = data.data.data;
                let num = 0;
                if (data.respCode === "S" && list.length > 0) {
                    if (status === "IN_PROGRESS") {
                        list.forEach(item => {
                            item.procureTaskItems.forEach(i => {
                                num++;
                                if (i.taskPrice > i.actPrice) {
                                    i.disabled = true
                                } else {
                                    i.disabled = false;
                                }
                            });
                        });
                    }
                    if (self.currentPage == 1) {
                        self.total = num;
                        self.listData = list;
                    } else {
                        self.total = self.total + num;
                        self.listData = self.listData.concat(list);
                    }
                    self.totalPage = data.data.totalPage;

                    if (self.currentPage < self.totalPage) {
                        self.loading = false;
                    }
                } else {
                    self.listData = [];
                }
                if (self.orderType === 1 && self.listData.length > 0) {
                    self.upDataDate();
                }
            });
        },


        /**
         * 采买进行中已买
         * actQuantity:实际采买数量
         * procureTaskItemId:采买任务id
         */
        purchasedQuantity() {
            let self = this;
            if (
                parseInt(self.quantity) > parseInt(self.procureTaskItem.taskQuantity)
            ) {
                self.outOfStock_popup = false;
                self.otherMarket = false;
                self.errMsg = "数量不能大于需采买数量";
                setTimeout(() => {
                    self.errMsg = "";
                }, 1000);
                return;
            } else if (self.quantity != null) {
                self.outOfStock_popup = false;
                self.otherMarket = false;
                Axios.post("procurement/procureTaskItem/buyingProcurement.do", {
                    actQuantity: self.quantity,
                    procureTaskItemId: self.procureTaskItem.procureTaskItemId
                }).then(function (data) {
                    if (data.respCode === "S") {
                        self.currentPage = 1;
                        self.listData = [];
                        self.getProcureTaskItemList();
                    } else {
                        self.errMsg = data.errorMsg;
                        setTimeout(() => {
                            self.errMsg = "";
                        }, 1000);
                    }
                });
            } else {
                self.errMsg = "请输入采买数量";
                setTimeout(() => {
                    self.errMsg = "";
                }, 1000);
            }
        },

        // 更改订单商品
        changeOrderStatusOk() {
            let self = this;
            let num;
            if (self.procureStatus === "LACK") {
                num = Number(self.quantity);
            } else if (self.procureStatus === "PRICE_HIGH") {
                num = null;
            } else {
                num = 0;
            }
            Axios.post("procurement/procurement/updateProcurStatus.do", {
                goodsSkuId: self.listData[self.goodsIndex].goodsSkuId,
                procurementTaskIdList: self.listData[self.goodsIndex].procurementTaskIdList,
                quantity: num,
                status: self.procureStatus
            }).then(function (data) {
                if (data.respCode === "S") {
                    self.orderInfo.procureStatus = this.procureStatus;
                    self.loading = true;
                    self.currentPage = 1;
                    self.listData = [];
                    self.getData();
                    self.procureStatus = "";
                    self.quantity = null;
                    self.outOfStock_popup = false;
                    self.otherMarket = false;
                } else {
                    self.outOfStock_popup = false;
                    self.errMsg = data.errorType;
                    setTimeout(() => {
                        self.errMsg = "";
                    }, 1000);
                }
            });
        },

        /**
         *采买任务全选,确定按钮
         */
        postTaskId(procureMergeTasksId) {
            //TODO
            let self = this;
            let idList = [];
            if (self.orderType === 1) {
                let list = self.listData;
                idList = self.conductCheckModel;
                for (let i = 0; i < list.length; i++) {
                    list[i].procureTaskItems.forEach(item => {
                        for (let j = 0; j < idList; j++) {
                            if (idList[j] === item.procureTaskItemId) {
                                //actQuantity 已买数量
                                if (!item.actQuantity) {
                                    self.outOfStock_popup = true;
                                    self.promptOutOfStock = true;
                                    this.otherMarket = true;
                                    return;
                                }
                            }
                        }
                    });
                }
                Axios.post("/procurement/procureTaskItem/procureTaskItemDone.do", {
                    procureTaskItemIds: idList
                }).then(function (data) {
                    if (data.respCode === "S") {
                        self.conductCheckModel = [];
                        self.listData = [];
                        self.getProcureTaskItemList();
                        self.errMsg = data.data;
                        setTimeout(() => {
                            self.errMsg = "";
                        }, 1000);
                    } else {
                        self.errMsg = data.errorMsg;
                        setTimeout(() => {
                            self.errMsg = "";
                        }, 1000);
                    }
                });
            } else {
                procureMergeTasksId === null ?
                    (idList = self.checkModel) :
                    (idList[0] = procureMergeTasksId);
                Axios.post("/procurement/procureMergeTasks/grabTheOrder.do", {
                    procureMergeTasksIds: idList
                }).then(function (data) {
                    if (data.respCode === "S") {
                        self.checkModel = [];
                        self.listData = [];
                        self.getData();
                        self.errMsg = data.data;
                        setTimeout(() => {
                            self.errMsg = "";
                        }, 1000);
                    } else {
                        self.errMsg = data.errorMsg;
                        setTimeout(() => {
                            self.errMsg = "";
                        }, 1000);
                    }
                });
            }
        },

        //已完成的合并采买任务发货
        confirmDelivery(goodsSkuId, procureTimeStr, idList) {
            let self = this;
            self.procurementTaskIdList = idList;
            self.postTaskId();
        },
        dateFormat(t) {
            return t < 10 ? "0" + t : t;
        },
        showPopup(item) {
            if (!item.disabled) {
                return;
            }
            this.promptOutOfStock = false;
            this.procureTaskItem = item;
            this.quantity = null;
            this.outOfStock_popup = true;
            this.otherMarket = true;
        },
        closePopup() {
            this.outOfStock_popup = false;
            this.otherMarket = false;
            this.listData[this.goodsIndex].procureStatus = "";
        },
        hidePriceShareBox(e) {
            let self = this;
            if (e.target.className !== "buyTaskDetail-container") {
                return;
            } else {
                self.outOfStock_popup = false;
                self.otherMarket = false;
                self.listData[self.goodsIndex].procureStatus = "";
            }
        },
        format(date) {
            if (date) {
                let d = new Date(date).Format("yy-MM-dd hh:mm:ss"); //"2018-11-15 17:40:00"
                return d;
            }
        },
        // 选择超市弹窗展开
        changeMarket() {
            this.marketKey = "";
            this.marketData = null;
            const choiceMarket = this.$refs.choiceMarket;
            choiceMarket.show();
        },
        // 右侧选择超市弹窗无限加载超市列表数据
        marketDataMore() {
            this.currentPage++;
            if (this.currentPage > this.totalPage) {
                this.$refs.marketData.forceUpdate();
                return;
            }
            this.getMarketData();
        },
        // 右侧选择超市弹窗获取超市列表数据
        getMarketData() {
            Axios.post("area/Supermarket/getSupermarketByKey.do", {
                key: this.marketKey,
                currentPage: 1,
                pageSize: 20
            }).then(res => {
                if (res.respCode === "S") {
                    let list = res.data.data;
                    let reg = new RegExp(this.marketKey, "g");
                    list.forEach(item => {
                        item.name = item.name.replace(reg, "<i>" + this.marketKey + "</i>");
                    });
                    if (this.currentPage === 1) {
                        this.marketData = list;
                    } else {
                        this.marketData = this.marketData.concat(list);
                    }
                    this.totalPage = res.data.totalPage;

                    if (this.currentPage >= this.totalPage) {
                        this.$refs.marketData.forceUpdate();
                    }
                }
            });
        },
        // 右侧选择超市弹窗选择超市
        choiceMarket(item) {
            let reg = new RegExp("<i>", "g");
            let reg1 = new RegExp("</i>", "g");
            item.name = item.name.replace(reg, "");
            item.name = item.name.replace(reg1, "");
            this.market.marketName = item.name;
            this.market.supermarketId = item.supermarketId;
            this.params.supermarketId = item.supermarketId;
            localStorage.setItem("market", JSON.stringify(this.market));
            this.changeMarketTitle = "修改超市";
            const choiceMarket = this.$refs.choiceMarket;
            choiceMarket.hide();
            this.currentPage = 1;
            this.listData = null;
            this.loading = false;
            this.getData();
        },
        //价格纠错
        priceCorrection(item, index, key) {
            console.log(item.disabled)
            if (item.disabled === true) {
                return;
            }
            let self = this;
            self.sequence.index = index;
            self.headerTitle = "任务明细";
            self.sequence.key = key;
            self.showType = 1;
            console.log(
                self.listData[self.sequence.index].procureTaskItems[self.sequence.key]
            );
        },
        // 选择价格类型
        choicePriceType() {
            this.$createActionSheet({
                data: [{
                    content: "正常价"
                },
                {
                    content: "促销价"
                },
                {
                    content: "处理价"
                },
                {
                    content: "会员价"
                }
                ],
                onSelect: (item, index) => {
                    this.params.priceType = item.content;
                },
                onCancel: () => { }
            }).show();
        },
        // 开始时间弹窗
        choiceStartAndEndTime() {
            this.startAndEndTime();
            this.startAndEndTimePicker.show();
        },
        startAndEndTime() {
            let dateSegmentData = [{
                is: "cube-date-picker",
                title: "开始时间",
                min: new Date(),
                max: new Date(2030, 12, 31, 23, 59),
                columnCount: 5
            },
            {
                is: "cube-date-picker",
                title: "结束时间",
                min: new Date(),
                max: new Date(2030, 12, 31, 23, 59),
                columnCount: 5
            }
            ];
            this.startAndEndTimePicker = this.$createSegmentPicker({
                data: dateSegmentData,
                onSelect: (selectedDates, selectedVals, selectedTexts) => {
                    let startTime = selectedTexts[0];
                    let endTime = selectedTexts[1];
                    this.params.startTime =
                        startTime[0] +
                        "-" +
                        startTime[1] +
                        "-" +
                        startTime[2] +
                        " " +
                        startTime[3] +
                        ":" +
                        startTime[4];
                    this.params.endTime =
                        endTime[0] +
                        "-" +
                        endTime[1] +
                        "-" +
                        endTime[2] +
                        " " +
                        endTime[3] +
                        ":" +
                        endTime[4];
                },
                onNext: (i, selectedDate, selectedValue, selectedText) => {
                    dateSegmentData[1].min = selectedDate;
                    if (i === 0) {
                        this.startAndEndTimePicker.$updateProps({
                            data: dateSegmentData
                        });
                    }
                }
            });
        },

        //数据校验
        checkParam() {
            let data = this.params;
            for (let i in data) {
                if (i === "priceType") {
                    if (data[i] === "请选择价格类型" || data[i] === "") {
                        this.toast = this.$createToast({
                            txt: "请填选择价格类型",
                            type: "txt"
                        });
                        this.toast.show();
                        return false;
                    }
                } else if (i === "startTime") {
                    if (data[i] === "请选择开始时间" || data[i] === "") {
                        this.toast = this.$createToast({
                            txt: "请选择开始时间",
                            type: "txt"
                        });
                        this.toast.show();
                        return false;
                    }
                } else if (i === "endTime") {
                    if (data[i] === "请选择结束时间" || data[i] === "") {
                        this.toast = this.$createToast({
                            txt: "请选择结束时间",
                            type: "txt"
                        });
                        this.toast.show();
                        return false;
                    }
                } else if (i === "price") {
                    if (data[i] === 0 || data[i] === null) {
                        this.toast = this.$createToast({
                            txt: "请输入商品价格",
                            type: "txt"
                        });
                        this.toast.show();
                        return false;
                    }
                }
            }
            return true;
        },
        /***
         * 分享/纠错提交
         * price
         * startTime
         * endTime
         * priceType
         * procureTaskItemId
         */
        shareAndCorrectionSubmit() {
            let self = this;
            let datas = self.params;
            datas.procureTaskItemId =
                self.listData[self.sequence.index].procureTaskItems[
                    self.sequence.key
                ].procureTaskItemId;
            self.btnDisabled = true;
            let F = new FormData();
            if (self.checkParam()) {
                for (let i in datas) {
                    if (i === "priceType") {
                        if (datas[i] === "正常价") {
                            F.append(i, "NORMAL");
                        } else if (datas[i] === "促销价") {
                            F.append(i, "PROMOTION");
                        } else if (datas[i] === "处理价") {
                            F.append(i, "DEAL");
                        } else if (datas[i] === "会员价") {
                            F.append(i, "MEMBER");
                        }
                    } else {
                        F.append(i, datas[i]);
                    }
                }
            } else {
                self.btnDisabled = false;
                return;
            }
            Axios.post("correct/correct/save.do", F)
                .then(res => {
                    if (res.respCode === "S") {
                        self.currentPage = 1;
                        self.listData = [];
                        self.getProcureTaskItemList();
                        self.showType = 0;
                        self.resetShareAndCorrection();
                        self.btnDisabled = false;
                        self.toast = self.$createToast({
                            txt: res.data,
                            type: "txt"
                        });
                        self.toast.show();
                    } else {
                        self.toast = self.$createToast({
                            txt: res.errorMsg,
                            type: "txt"
                        });
                        self.toast.show();
                    }
                })
                .catch(err => {
                    console.error(err);
                });
        },
        // 重置分享纠错数据
        resetShareAndCorrection() {
            // 商品分享纠错所传参数
            this.params.price = null;
            this.params.priceType = "请选择价格类型";
            this.params.startTime = "请选择开始时间";
            this.params.endTime = "请选择结束时间";
            this.procureTaskItem = null;
        },

        //倒计时
        upDataDate() {
            let T = "";
            let clock = window.setInterval(() => {
                if (this.orderType === 1 && this.listData.length > 0) {
                    for (let i = 0; i < this.listData.length; i++) {
                        var R = new Date(this.listData[i].dueTime) - new Date(); //剩余毫秒数
                        let H = "";
                        let M = "";
                        let S = "";
                        if (R <= 0) {
                            this.listData.splice(i, 1);
                            //返回待完成
                            if (this.showType === 2) {
                                this.showType = 0;
                                this.orderType = 1;
                            }
                        } else {
                            D = parseInt(R / 1000 / 60 / 60 / 24, 10);
                            D <= 0 ? (D = "") : (D = D + ":");

                            H = parseInt((R / 1000 / 60 / 60) % 24, 10);
                            H < 10 ? (H = "0" + H) : H;

                            M = parseInt((R / 1000 / 60) % 60, 10); //剩余分钟
                            M < 10 ? (M = ":0" + M) : (M = ":" + M);

                            S = parseInt((R / 1000) % 60, 10); //剩余秒数
                            S < 10 ? (S = ":0" + S) : (S = ":" + S);

                            T = "倒计时：" + D + H + M + S;
                            this.listData[i].createTime = T;
                        }
                    }
                }
            }, 1000);
        },
        // 加载历史列表
        historyDataMore() {
            this.currentPage++;
            if (this.currentPage > this.totalPage) {
                this.$refs.historyData.forceUpdate();
                return;
            }
            this.getHistoryData(this.historyStatus);
        },
        // 获取历史列表
        getHistoryData(int) {
            this.historyStatus = int;
            if (this.historyStatus == 0) {
                Axios.post(
                    "procurement/procureMergeTasks/getHistoryProcureMergeTasks.do", {
                        pageSize: this.pageSize,
                        currentPage: this.currentPage,
                        supermarketId: this.market.supermarketId,
                        createTimeStart: this.startTime,
                        createTimeEnd: this.endTime
                    }
                ).then(res => {
                    if (res.respCode === "S") {
                        let list = res.data.data;
                        if (this.currentPage === 1) {
                            this.historyData = list;
                        } else {
                            this.historyData = this.historyData.concat(list);
                        }
                        this.totalPage = res.data.totalPage;

                        if (this.currentPage >= this.totalPage) {
                            this.$refs.historyData.forceUpdate();
                        } else {
                            this.pullUpLoad = true;
                        }
                    }
                });
            } else {
                Axios.post("correct/correct/historyForCorrect.do", {
                    pageSize: this.pageSize,
                    currentPage: this.currentPage,
                    supermarketId: this.market.supermarketId,
                    createTimeStart: this.startTime,
                    createTimeEnd: this.endTime,
                    correctWay: "BUYTASK"
                }).then(res => {
                    if (res.respCode === "S") {
                        let list = res.data.data;
                        console.log(res);
                        // list.forEach(item => {
                        //   item.createTime = new Date(item.dealTime).Format("yy/MM/dd");
                        //   item.price = item.priceAudit / 100 + "元";
                        // });
                        if (this.currentPage === 1) {
                            this.historyData = list;
                        } else {
                            this.historyData = this.historyData.concat(list);
                        }
                        this.totalPage = res.data.totalPage;

                        if (this.currentPage >= this.totalPage) {
                            this.$refs.historyData.forceUpdate();
                        } else {
                            this.pullUpLoad = true;
                        }
                    }
                });
            }
        },
        historyScreen() {
            this.historyScreenTime();
            this.screenTimePicker.show();
        },
        // 价格纠错开始时间和结束时间弹窗初始化
        historyScreenTime() {
            let dateSegmentData = [{
                is: "cube-date-picker",
                title: "开始时间",
                min: new Date(2019, 0, 1),
                max: new Date(2030, 12, 31),
                columnCount: 3
            },
            {
                is: "cube-date-picker",
                title: "结束时间",
                min: new Date(2019, 0, 1),
                max: new Date(2030, 12, 31),
                columnCount: 3
            }
            ];
            this.screenTimePicker = this.$createSegmentPicker({
                data: dateSegmentData,
                onSelect: (selectedDates, selectedVals, selectedTexts) => {
                    let startTime = selectedTexts[0];
                    let endTime = selectedTexts[1];
                    this.startTime =
                        startTime[0] +
                        "-" +
                        startTime[1] +
                        "-" +
                        startTime[2] +
                        " 00:00:00";
                    this.endTime =
                        endTime[0] + "-" + endTime[1] + "-" + endTime[2] + " 23:59:59";
                    this.currentPage = 1;
                    this.pullUpLoad = false;
                    this.getHistoryData(this.historyStatus);
                },
                onNext: (i, selectedDate, selectedValue, selectedText) => {
                    dateSegmentData[1].min = selectedDate;
                    if (i === 0) {
                        this.screenTimePicker.$updateProps({
                            data: dateSegmentData
                        });
                    }
                }
            });
        }
    },
    computed: {
        scrollOptions() {
            return {
                pullUpLoad: this.pullUpLoadObj
            };
        },
        pullUpLoadObj: function () {
            return this.pullUpLoad ?
                {
                    threshold: parseInt(this.pullUpLoadThreshold),
                    txt: {
                        noMore: this.pullUpLoadNoMoreTxt
                    }
                } :
                false;
        }
    },
    created() {
        let market = JSON.parse(localStorage.getItem("market"));
        if (market) {
            this.market.marketName = market.marketName;
            this.market.supermarketId = market.supermarketId;
            this.params.supermarketId = market.supermarketId;
            this.changeMarketTitle = "选择超市";
        }
    }
});